<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let obj = {
            name: 'ikun',
            age: 32
        }
        //传统赋值
        // let name=obj.name
        // let age=obj.age

        //解构赋值
        let { name, age } = obj
        console.log(name, age)

        // 取出变量值，赋值给对象
        let username = 'admin'
        let password = '123456'
        let code = '232222'

        // 传统写法
        // let user={
        //     username:username,
        //     password:password,
        //     code:code
        // }

        // ES6新写法
        let user = {
            username,
            password,
            code,
            eat() {
                console.log('我要吃饭了');
            }
        }
    </script>
</body>

</html>